home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Utilities / Font Management Utility / ChineseS / Xerox Font Management Utility.msi / Data1.cab / fmu.chm3 / skinsupport / madcapeffects.js < prev    next >
Text File  |  2011-04-21  |  25KB  |  973 lines

  1. /// <reference path="MadCapUtilities.js" />
  2. /// <reference path="MadCapMerging.js" />
  3.  
  4. // {{MadCap}} //////////////////////////////////////////////////////////////////
  5. // Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////
  6. ////////////////////////////////////////////////////////////////////////////////
  7. // <version>6.1.0.0</version>
  8. ////////////////////////////////////////////////////////////////////////////////
  9.  
  10. var gPopupObj           = null;
  11. var gPopupBGObj         = null;
  12. var gJustPopped         = false;
  13.  
  14. var gFadeID             = 0;
  15.  
  16. var gTextPopupBody      = null;
  17. var gTextPopupBodyBG    = null;
  18.  
  19. var gImgNode            = null;
  20.  
  21. function FMCImageSwap( img, swapType )
  22. {
  23.     var state    = FMCGetMCAttribute( img, "MadCap:state" );
  24.     
  25.     switch ( swapType )
  26.     {
  27.         case "swap":
  28.             var src        = img.src;
  29.             var altsrc2    = FMCGetMCAttribute( img, "MadCap:altsrc2" );
  30.             
  31.             if ( !altsrc2 )
  32.             {
  33.                 altsrc2 = FMCGetMCAttribute( img, "MadCap:altsrc" );
  34.             }
  35.             
  36.             img.src = altsrc2;
  37.             img.setAttribute( "MadCap:altsrc2", src );
  38.             img.setAttribute( "MadCap:state", (state == null || state == "close") ? "open" : "close" );
  39.             
  40.             break;
  41.             
  42.         case "open":
  43.             if ( state != swapType )
  44.             {
  45.                 FMCImageSwap( img, "swap" );
  46.             }
  47.             
  48.             break;
  49.             
  50.         case "close":
  51.             if ( state == "open" )
  52.             {
  53.                 FMCImageSwap( img, "swap" );
  54.             }
  55.             
  56.             break;
  57.     }
  58. }
  59.  
  60. function FMCExpandAll( swapType )
  61. {
  62.     var nodes   = FMCGetElementsByAttribute( document.body, "MadCap:targetName", "*" );
  63.     
  64.     for ( var i = 0; i < nodes.length; i++ )
  65.     {
  66.         nodes[i].style.display = (swapType == "open") ? "" : "none";
  67.     }
  68.     
  69.     nodes = FMCGetElementsByClassRoot( document.body, "MCTogglerIcon" );
  70.     
  71.     for ( var i = 0; i < nodes.length; i++ )
  72.     {
  73.         FMCImageSwap( nodes[i], swapType );
  74.     }
  75.     
  76.     nodes = FMCGetElementsByClassRoot( document.body, "MCExpandingBody" );
  77.     
  78.     for ( var i = 0; i < nodes.length; i++ )
  79.     {
  80.         nodes[i].style.display = (swapType == "open") ? "" : "none";
  81.     }
  82.     
  83.     nodes = FMCGetElementsByClassRoot( document.body, "MCExpandingIcon" );
  84.     
  85.     for ( var i = 0; i < nodes.length; i++ )
  86.     {
  87.         FMCImageSwap( nodes[i], swapType );
  88.     }
  89.     
  90.     nodes = FMCGetElementsByClassRoot( document.body, "MCDropDownBody" );
  91.     
  92.     for ( var i = 0; i < nodes.length; i++ )
  93.     {
  94.         nodes[i].style.display = (swapType == "open") ? "" : "none";
  95.     }
  96.     
  97.     nodes = FMCGetElementsByClassRoot( document.body, "MCDropDownIcon" );
  98.     
  99.     for ( var i = 0; i < nodes.length; i++ )
  100.     {
  101.         FMCImageSwap( nodes[i], swapType );
  102.     }
  103. }
  104.  
  105. function FMCDropDown( node )
  106. {
  107.     // Find head node
  108.     
  109.     var headNode    = node;
  110.     
  111.     while ( !FMCContainsClassRoot( headNode.className, "MCDropDown", "GlossaryPageEntry" ) )
  112.     {
  113.         headNode = headNode.parentNode;
  114.     }
  115.     
  116.     // Toggle the icon
  117.     
  118.     var imgNodes    = node.getElementsByTagName( "img" );
  119.     
  120.     for ( var i = 0; i < imgNodes.length; i++ )
  121.     {
  122.         var imgNode = imgNodes[i];
  123.         
  124.         if ( FMCContainsClassRoot( imgNode.className, "MCDropDownIcon" ) )
  125.         {
  126.             FMCImageSwap( imgNode, "swap" );
  127.             
  128.             break;
  129.         }
  130.     }
  131.     
  132.     // Hide/unhide the body
  133.     
  134.     var id              = node.id.substring( "MCDropDownHotSpot_".length, node.id.length );
  135.     var dropDownBody    = document.getElementById( "MCDropDownBody_" + id );
  136.     
  137.     dropDownBody.style.display = (dropDownBody.style.display == "none") ? "" : "none";
  138. }
  139.  
  140. function FMCExpand( node )
  141. {
  142.     // Find top node
  143.     
  144.     while ( !FMCContainsClassRoot( node.className, "MCExpanding" ) )
  145.     {
  146.         node = node.parentNode;
  147.     }
  148.     
  149.     var nodes       = node.childNodes;
  150.     var imgNodes    = node.getElementsByTagName( "img" );
  151.     
  152.     // Toggle the icon
  153.     
  154.     for ( var i = 0; i < imgNodes.length; i++ )
  155.     {
  156.         var imgNode = imgNodes[i];
  157.         
  158.         if ( FMCContainsClassRoot( imgNode.className, "MCExpandingIcon" ) )
  159.         {
  160.             FMCImageSwap( imgNode, "swap" );
  161.             
  162.             break;
  163.         }
  164.     }
  165.     
  166.     // Hide/unhide the body
  167.     
  168.     var expandingBody;
  169.     
  170.     for ( i = 0; i < nodes.length; i++ )
  171.     {
  172.         var node = nodes[i];
  173.         
  174.         if ( FMCContainsClassRoot( node.className, "MCExpandingBody" ) )
  175.         {
  176.             expandingBody = node;
  177.             break;
  178.         }
  179.     }
  180.     
  181.     expandingBody.style.display = (expandingBody.style.display == "none") ? "" : "none";
  182. }
  183.  
  184. var gPopupNumber    = 0;
  185.  
  186. function FMCPopup( e, node )
  187. {
  188.     // Don't continue if something is already popped up
  189.  
  190.     if ( gPopupObj )
  191.     {
  192.         return;
  193.     }
  194.  
  195.     if ( !e )
  196.     {
  197.         e = window.event;
  198.     }
  199.  
  200.     if ( FMCInPreviewMode() && document.documentElement.innerHTML.indexOf( "<!-- saved from url" ) != -1 )
  201.     {
  202.         var span    = document.getElementById( "MCTopicPopupWarning" );
  203.         
  204.         if ( !span )
  205.         {
  206.             span = document.createElement( "span" );
  207.             span.id = "MCTopicPopupWarning";
  208.             span.className = "MCTextPopupBody";
  209.             span.style.display = "none";
  210.             span.appendChild( document.createTextNode( "Topic popups can not be displayed when Insert Mark of the Web is enabled in the target." ) );
  211.             
  212.             document.body.appendChild( span );
  213.         }
  214.         
  215.         gTextPopupBody = span;
  216.         
  217.         FMCShowTextPopup( e );
  218.         
  219.         return;
  220.     }
  221.  
  222.     // Toggle the icon
  223.  
  224.     var imgNodes    = node.getElementsByTagName( "img" );
  225.  
  226.     for ( var i = 0; i < imgNodes.length; i++ )
  227.     {
  228.         var imgNode = imgNodes[i];
  229.         
  230.         if ( FMCContainsClassRoot( imgNode.className, "MCExpandingIcon" ) )
  231.         {
  232.             FMCImageSwap( imgNode, "swap" );
  233.             gImgNode = imgNode;
  234.             
  235.             break;
  236.         }
  237.     }
  238.  
  239.     // Create iframe node
  240.  
  241.     var name            = FMCGetAttribute( node, "MadCap:iframeName" );
  242.     var iframeExists    = name != null;
  243.     var iframe            = null;
  244.     
  245.     if ( iframeExists )
  246.     {
  247.         iframe = document.getElementById( name );
  248.     }
  249.     else
  250.     {
  251.         var src        = FMCGetAttribute( node, "MadCap:src" );
  252.         var path    = null;
  253.  
  254.         if ( src.StartsWith( "http" ) || FMCInPreviewMode() )
  255.         {
  256.             path = src;
  257.         }
  258.         else
  259.         {
  260.             var currentUrl    = document.location.href;
  261.             
  262.             path = currentUrl.substring( 0, currentUrl.lastIndexOf( "/" ) + 1 )
  263.             path = path + src;
  264.         }
  265.  
  266.         try
  267.         {
  268.             // For IE
  269.             
  270.             iframe = document.createElement( "<iframe onload='FMCIFrameOnloadInline( this );'>" );
  271.         }
  272.         catch ( ex )
  273.         {
  274.             // For non-IE
  275.             
  276.             iframe = document.createElement( "iframe" );
  277.             iframe.onload = FMCIFrameOnload;
  278.         }
  279.  
  280.         var name    = "MCPopup_" + (gPopupNumber++);
  281.         
  282.         node.setAttribute( "MadCap:iframeName", name );
  283.         
  284.         iframe.name = name;
  285.         iframe.id = name;
  286.         iframe.className = "MCPopupBody";
  287.         iframe.setAttribute( "title", "Popup" );
  288.         iframe.setAttribute( "scrolling", "auto" );
  289.         iframe.setAttribute( "frameBorder", "0" );
  290.  
  291.         var width = FMCGetAttribute( node, "MadCap:width" );
  292.         
  293.         if ( width != null )
  294.         {
  295.             iframe.setAttribute( "MadCap:width", width );
  296.         }
  297.         
  298.         var height = FMCGetAttribute( node, "MadCap:height" );
  299.         
  300.         if ( height != null )
  301.         {
  302.             iframe.setAttribute( "MadCap:height", height );
  303.         }
  304.  
  305.         document.body.appendChild( iframe );
  306.         
  307.         iframe.src = path;
  308.     }
  309.     
  310.     iframe.style.display = "none";
  311.     
  312.     //
  313.     
  314.     gJustPopped = true;
  315.         
  316.     iframe.MCClientX = e.clientX + FMCGetScrollLeft(window);
  317.     iframe.MCClientY = e.clientY + FMCGetScrollTop(window);
  318.     
  319.     if ( iframeExists )
  320.     {
  321.         FMCShowIFrame( iframe );
  322.     }
  323. }
  324.  
  325. function FMCIFrameOnload( e )
  326. {
  327.     // Safari will fire the onload event twice. Once for creating the iframe (about:blank). The second time for setting the src of the iframe.
  328.  
  329.     if ( this.contentWindow.document.location.href == "about:blank" )
  330.     {
  331.         return;
  332.     }
  333.  
  334.     // Navigating to a link in the popup will fire onload again.
  335.  
  336.     if ( FMCGetAttributeBool( this, "MadCap:loaded", false ) )
  337.     {
  338.         return;
  339.     }
  340.  
  341.     FMCShowIFrame( this );
  342.  
  343.     this.setAttribute( "MadCap:loaded", "true" );
  344. }
  345.  
  346. function FMCIFrameOnloadInline( popupBody )
  347. {
  348.     // Navigating to a link in the popup will fire onload again.
  349.     
  350.     if ( FMCGetAttributeBool( popupBody, "MadCap:loaded", false ) )
  351.     {
  352.         return;
  353.     }
  354.     
  355.     FMCShowIFrame( popupBody );
  356.     
  357.     popupBody.setAttribute( "MadCap:loaded", "true" );
  358. }
  359.  
  360. function FMCShowIFrame( popupBody )
  361. {
  362.     try
  363.     {
  364.         // Access denied on document when linking to external website
  365.         
  366.         if ( popupBody.contentWindow.document.location.href == "about:blank" )
  367.         {
  368.             return;
  369.         }
  370.     }
  371.     catch ( ex )
  372.     {
  373.     }
  374.     
  375.     popupBody.style.display = "";
  376.     FMCSetPopupSize( popupBody );
  377.     
  378.     var clientX = popupBody.MCClientX;
  379.     var clientY = popupBody.MCClientY;
  380.     var newXY = FMCGetInBounds( popupBody, clientX, clientY );
  381.     
  382.     popupBody.style.left = newXY.X + "px";
  383.     popupBody.style.top = newXY.Y + "px";
  384.     
  385.     // Set up background
  386.     
  387.     var popupBodyBG = document.createElement( "span" );
  388.     
  389.     popupBodyBG.className = "MCPopupBodyBG";
  390.     popupBodyBG.style.top = newXY.Y + 5 + "px";
  391.     popupBodyBG.style.left = newXY.X + 5 + "px";
  392.     popupBodyBG.style.width = parseInt( popupBody.offsetWidth ) + "px";
  393.     popupBodyBG.style.height = parseInt( popupBody.offsetHeight ) + "px";
  394.     
  395.     popupBody.parentNode.appendChild( popupBodyBG );
  396.     gPopupObj = popupBody;
  397.     gPopupBGObj = popupBodyBG;
  398.     
  399.     //
  400.     
  401.     gFadeID = setInterval( FMCFade, 10 );
  402. }
  403.  
  404. function FMCGetInBounds(el, x, y)
  405. {
  406.     var absolutePosition = FMCGetPosition(el.offsetParent);
  407.     var absoluteTop = absolutePosition[0];
  408.     var absoluteLeft = absolutePosition[1];
  409.     var scrollTop = FMCGetScrollTop(window);
  410.     var scrollLeft = FMCGetScrollLeft(window);
  411.     var newTop = y;
  412.     var newLeft = x;
  413.  
  414.     if (y < scrollTop)
  415.     {
  416.         newTop = scrollTop + 5; // "+ 5" is for some extra padding.
  417.     }
  418.  
  419.     if (x < scrollLeft)
  420.     {
  421.         newLeft = scrollLeft + 5; // "+ 5" is for some extra padding.
  422.     }
  423.  
  424.     // "+ 5" is to account for width of popup shadow.
  425.  
  426.     if (newTop + parseInt(el.style.height) + 5 > scrollTop + FMCGetClientHeight(window, false))
  427.     {
  428.         newTop = scrollTop + FMCGetClientHeight(window, false) - parseInt(el.style.height) - 5;
  429.     }
  430.  
  431.     newTop -= absoluteTop;
  432.  
  433.     if (newLeft + parseInt(el.style.width) + 5 > scrollLeft + FMCGetClientWidth(window, false))
  434.     {
  435.         newLeft = scrollLeft + FMCGetClientWidth(window, false) - parseInt(el.style.width) - 5;
  436.     }
  437.  
  438.     newLeft -= absoluteLeft;
  439.  
  440.     return { X: newLeft, Y: newTop };
  441. }
  442.  
  443. function FMCSetPopupSize( popupNode )
  444. {
  445.     var popupWidth    = FMCGetAttribute( popupNode, "MadCap:width" );
  446.     var popupHeight    = FMCGetAttribute( popupNode, "MadCap:height" );
  447.     
  448.     if ( (popupWidth != "auto" && !String.IsNullOrEmpty( popupWidth )) || (popupHeight != "auto" && !String.IsNullOrEmpty( popupHeight )) )
  449.     {
  450.         popupNode.style.width = popupWidth;
  451.         popupNode.style.height = popupHeight;
  452.         
  453.         return;
  454.     }
  455.     
  456.     //
  457.     
  458.     var clientWidth     = FMCGetClientWidth( window, false );
  459.     var clientHeight    = FMCGetClientHeight( window, false );
  460.     var stepSize        = 10;
  461.     var hwRatio         = clientHeight / clientWidth;
  462.     var popupFrame      = frames[popupNode.name];
  463.     var maxX            = clientWidth * 0.618034;
  464.     var i               = 0;
  465.     
  466.     // Debug
  467.     //window.status += document.body.clientHeight + ", " + document.body.offsetHeight + ", " + document.body.scrollHeight + ", " + document.body.scrollTop;
  468.     //window.status += " : " + document.documentElement.clientHeight + ", " + document.documentElement.offsetHeight + ", " + document.documentElement.scrollHeight + ", " + document.documentElement.scrollTop;
  469.     
  470.     // Safari
  471.     
  472.     if ( FMCIsSafari() )
  473.     {
  474.         popupNode.style.width = maxX + "px";
  475.         popupNode.style.height = (maxX * hwRatio) + "px";
  476.         
  477.         return;
  478.     }
  479.     
  480.     //
  481.     
  482.     try
  483.     {
  484.         var popupDocument   = popupFrame.document; // This will throw an exception in IE.
  485.         
  486.         FMCGetScrollHeight( popupFrame.window );   // This will throw an exception in Mozilla.
  487.     }
  488.     catch ( err )
  489.     {
  490.         popupNode.style.width = maxX + "px";
  491.         popupNode.style.height = (maxX * hwRatio) + "px";
  492.         
  493.         return;
  494.     }
  495.     
  496.     while ( true )
  497.     {
  498.         popupNode.style.width = maxX - (i * stepSize) + "px";
  499.         popupNode.style.height = (maxX - (i * stepSize)) * hwRatio + "px";
  500.         
  501.         if ( FMCGetScrollHeight( popupFrame.window ) > FMCGetClientHeight( popupFrame.window, false ) ||
  502.              FMCGetScrollWidth( popupFrame.window ) > FMCGetClientWidth( popupFrame.window, false ) )
  503.         {
  504.             popupNode.style.width = maxX - ((i - 1) * stepSize) + "px";
  505.             popupNode.style.height = (maxX - ((i - 1) * stepSize)) * hwRatio + "px";
  506.             
  507.             break;
  508.         }
  509.         
  510.         i++;
  511.     }
  512. }
  513.  
  514. function FMCPopupThumbnail_Onclick( e, node )
  515. {
  516.     // Don't continue if something is already popped up
  517.  
  518.     if ( gPopupObj )
  519.     {
  520.         return;
  521.     }
  522.  
  523.     if ( !e )
  524.     {
  525.         e = window.event;
  526.     }
  527.     
  528.     //
  529.     
  530.     var clientCenter = FMCGetClientCenter( window );
  531.     var img = FMCPopupThumbnailShow( node, clientCenter[0], clientCenter[1] );
  532.     var index = gDocumentOnclickFuncs.push( OnDocumentClick ) - 1;
  533.     var justPopped = true;
  534.     
  535.     function OnDocumentClick()
  536.     {
  537.         if ( justPopped )
  538.         {
  539.             justPopped = false;
  540.             return;
  541.         }
  542.         
  543.         FMCRemoveOpacitySheet( window );
  544.         
  545.         img.parentNode.removeChild( img );
  546.         
  547.         gDocumentOnclickFuncs.splice( index, 1 );
  548.     }
  549. }
  550.  
  551. function FMCPopupThumbnail_Onmouseover( e, node )
  552. {
  553.     // Don't continue if something is already popped up
  554.  
  555.     if ( gPopupObj )
  556.     {
  557.         return;
  558.     }
  559.  
  560.     if ( !e )
  561.     {
  562.         e = window.event;
  563.     }
  564.     
  565.     //
  566.     
  567.     var mouseX = FMCGetClientX( window, e );
  568.     var mouseY = FMCGetClientY( window, e );
  569.     var x = mouseX + FMCGetScrollLeft(window);
  570.     var y = mouseY + FMCGetScrollTop(window);
  571.     var img = FMCPopupThumbnailShow( node, x, y );
  572.     
  573.     img.onmouseout = Onmouseout;
  574.     
  575.     function Onmouseout()
  576.     {
  577.         FMCRemoveOpacitySheet( window );
  578.         
  579.         img.parentNode.removeChild( img );
  580.     }
  581. }
  582.  
  583. function FMCPopupThumbnailShow( node, x, y )
  584. {
  585.     var popupSrc = FMCGetAttribute( node, "MadCap:popupSrc" );
  586.     var popupWidth = FMCGetAttribute( node, "MadCap:popupWidth" );
  587.     var popupHeight = FMCGetAttribute( node, "MadCap:popupHeight" );
  588.  
  589.     var img = document.createElement( "img" );
  590.     img.className = "MCPopupThumbnail_Popup";
  591.     img.setAttribute( "src", popupSrc );
  592.     img.style.width = popupWidth + "px";
  593.     img.style.height = popupHeight + "px";
  594.     
  595.     var left = Math.max( 5, x - (popupWidth / 2) );
  596.     var top = Math.max( 5, y - (popupHeight / 2) );
  597.     
  598.     document.body.appendChild( img );
  599.     
  600.     var newXY = FMCGetInBounds( img, left, top );
  601.     
  602.     img.style.left = newXY.X + "px";
  603.     img.style.top = newXY.Y + "px";
  604.     
  605.     FMCInsertOpacitySheet( window, "#eeeeee" );
  606.     
  607.     MCFader.FadeIn( img, 0, 100, null, 0, 0, false );
  608.     
  609.     return img;
  610. }
  611.  
  612. function GetHelpControlLinks( node, callbackFunc, callbackArgs )
  613. {
  614.     var linkMap = new Array();
  615.     var inPreviewMode = FMCInPreviewMode();
  616.  
  617.     if ( !inPreviewMode )
  618.     {
  619.         var masterHS = FMCGetRootFrame().FMCGetHelpSystem();
  620.         
  621.         if ( masterHS.IsMerged() )
  622.         {
  623.             if ( FMCGetMCAttribute( node, "MadCap:indexKeywords" ) != null )
  624.             {
  625.                 function OnInit()
  626.                 {
  627.                     var indexKeywords   = FMCGetMCAttribute( node, "MadCap:indexKeywords" ).replace( "\\;", "%%%%%" );
  628.                     
  629.                     if ( indexKeywords == "" )
  630.                     {
  631.                         callbackFunc( linkMap, callbackArgs );
  632.                     }
  633.                     
  634.                     var keywords        = indexKeywords.split( ";" );
  635.                     
  636.                     for ( var i = 0; i < keywords.length; i++ )
  637.                     {
  638.                         keywords[i] = keywords[i].replace( "%%%%%", ";" );
  639.                         
  640.                         var currKeyword = keywords[i].replace( "\\:", "%%%%%" );
  641.                         var keywordPath = currKeyword.split( ":" );
  642.                         var level       = keywordPath.length - 1;
  643.                         var indexKey    = level + "_" + keywordPath[level].replace( "%%%%%", ":" );
  644.                         
  645.                         var currLinkMap = indexFrame.gLinkMap.GetItem( indexKey.toLowerCase() );
  646.                         
  647.                         // currLinkMap may be blank if keywords[i] isn't found in index XML file (user may have deleted keyword after associating it with a K-Link)
  648.                         
  649.                         if ( currLinkMap )
  650.                         {
  651.                             currLinkMap.ForEach( function( key, value )
  652.                             {
  653.                                 linkMap[linkMap.length] = key + "|" + value;
  654.                                 
  655.                                 return true;
  656.                             } );
  657.                         }
  658.                     }
  659.  
  660.                     callbackFunc( linkMap, callbackArgs );
  661.                 }
  662.  
  663.                 var rootFrame = FMCGetRootFrame();
  664.                 var indexFrame = rootFrame.frames["navigation"].frames["index"];
  665.                 
  666.                 indexFrame.Index_Init( OnInit );
  667.  
  668.                 return;
  669.             }
  670.             else if ( FMCGetMCAttribute( node, "MadCap:concepts" ) != null )
  671.             {
  672.                 var concepts    = FMCGetMCAttribute( node, "MadCap:concepts" );
  673.                 var args        = { callbackFunc: callbackFunc, callbackArgs: callbackArgs };
  674.                 
  675.                 masterHS.GetConceptsLinks( concepts, OnGetConceptsLinks, args );
  676.                 
  677.                 return;
  678.             }
  679.         }
  680.     }
  681.     
  682.     if ( FMCGetMCAttribute( node, "MadCap:topics" ) != null )
  683.     {
  684.         var topics  = FMCGetMCAttribute( node, "MadCap:topics" ).split( "||" );
  685.         
  686.         if ( topics == "" )
  687.         {
  688.             callbackFunc( linkMap, callbackArgs );
  689.         }
  690.         
  691.         for ( var i = 0; i < topics.length; i++ )
  692.         {
  693.             linkMap[linkMap.length] = topics[i];
  694.         }
  695.     }
  696.  
  697.     callbackFunc( linkMap, callbackArgs );
  698. }
  699.  
  700. function OnGetConceptsLinks( links, args )
  701. {
  702.     var callbackFunc    = args.callbackFunc;
  703.     var callbackArgs    = args.callbackArgs;
  704.     
  705.     callbackFunc( links, callbackArgs );
  706. }
  707.  
  708. function FMCTextPopup( e, node )
  709. {
  710.     // Don't continue if something is already popped up
  711.     
  712.     if ( gPopupObj )
  713.     {
  714.         return;
  715.     }
  716.     
  717.     if ( !e )
  718.     {
  719.         e = window.event;
  720.     }
  721.     
  722.     // Find top node
  723.     
  724.     while ( !FMCContainsClassRoot( node.className, "MCTextPopup" ) )
  725.     {
  726.         node = node.parentNode;
  727.     }
  728.     
  729.     // Toggle the icon
  730.     
  731.     var imgNodes    = node.getElementsByTagName( "img" );
  732.     
  733.     for ( var i = 0; i < imgNodes.length; i++ )
  734.     {
  735.         var imgNode = imgNodes[i];
  736.         
  737.         if ( FMCContainsClassRoot( imgNode.className, "MCExpandingIcon" ) )
  738.         {
  739.             FMCImageSwap( imgNode, "swap" );
  740.             gImgNode = imgNode;
  741.             
  742.             break;
  743.         }
  744.     }
  745.     
  746.     // Hide/unhide the body
  747.     
  748.     var nodes   = node.childNodes;
  749.     
  750.     for ( i = 0; i < nodes.length; i++ )
  751.     {
  752.         var node = nodes[i];
  753.         
  754.         if ( FMCContainsClassRoot( node.className, "MCTextPopupBody" ) )
  755.         {
  756.             gTextPopupBody = node;
  757.             break;
  758.         }
  759.     }
  760.     
  761.     FMCShowTextPopup( e );
  762. }
  763.  
  764. function FMCShowTextPopup( e )
  765. {
  766.     if ( gTextPopupBody.style.display == "none" )
  767.     {
  768.         if ( gTextPopupBody.childNodes.length == 0 )
  769.         {
  770.             gTextPopupBody.appendChild( document.createTextNode( "(No data to display)") );
  771.         }
  772.         
  773.         gTextPopupBody.style.display = "";
  774.         
  775.         FMCSetTextPopupSize( gTextPopupBody );
  776.         
  777.         // "+ 5" is to account for width of popup shadow.
  778.         
  779.         if ( FMCGetClientY( window, e ) + gTextPopupBody.offsetHeight + 5 > FMCGetClientHeight( window, false ) )
  780.         {
  781.             gTextPopupBody.style.top = FMCGetScrollTop( window ) + FMCGetClientHeight( window, false ) - gTextPopupBody.offsetHeight - 5 + "px";
  782.         }
  783.         else
  784.         {
  785.             gTextPopupBody.style.top = FMCGetPageY( window, e ) + "px";
  786.         }
  787.         
  788.         if ( FMCGetClientX( window, e ) + gTextPopupBody.offsetWidth + 5 > FMCGetClientWidth( window, false ) )
  789.         {
  790.             gTextPopupBody.style.left = FMCGetScrollLeft( window ) + FMCGetClientWidth( window, false ) - gTextPopupBody.offsetWidth - 5 + "px";
  791.         }
  792.         else
  793.         {
  794.             gTextPopupBody.style.left = FMCGetPageX( window, e ) + "px";
  795.         }
  796.         
  797.         // Set up background
  798.         
  799.         gTextPopupBodyBG = document.createElement( "span" );
  800.         gTextPopupBodyBG.className = "MCTextPopupBodyBG";
  801.         gTextPopupBodyBG.style.top = parseInt( gTextPopupBody.style.top ) + 5 + "px";
  802.         gTextPopupBodyBG.style.left = parseInt( gTextPopupBody.style.left ) + 5 + "px";
  803.         
  804.         FMCSetTextPopupDimensions();
  805.         
  806.         gTextPopupBody.parentNode.appendChild( gTextPopupBodyBG );
  807.         window.onresize = FMCSetTextPopupDimensions;
  808.         gPopupObj = gTextPopupBody;
  809.         gPopupBGObj = gTextPopupBodyBG;
  810.         gJustPopped = true;
  811.         
  812.         //
  813.         
  814.         gFadeID = setInterval( FMCFade, 10 );
  815.     }
  816. }
  817.  
  818. function FMCSetTextPopupSize( popupNode )
  819. {
  820.     var clientWidth     = FMCGetClientWidth( window, false );
  821.     var clientHeight    = FMCGetClientHeight( window, false );
  822.     var stepSize        = 10;
  823.     var hwRatio         = clientHeight / clientWidth;
  824.     var maxX            = clientWidth * 0.618034;
  825.     var i               = 0;
  826.     
  827.     while ( true )
  828.     {
  829.         popupNode.style.width = maxX - (i * stepSize) + "px";
  830.         popupNode.style.height = (maxX - (i * stepSize)) * hwRatio + "px";
  831.         
  832.         // "- 2" is to account for borderLeft + borderRight.
  833.         
  834.         if ( popupNode.scrollHeight > popupNode.offsetHeight - 2 || popupNode.scrollWidth > popupNode.offsetWidth - 2 )
  835.         {
  836.             popupNode.style.overflow = "hidden";    // Since scrollbars are now present, remove them before enlarging the node or else they'll still be present in Firefox and Safari
  837.             
  838.             popupNode.style.width = maxX - ((i - 1) * stepSize) + "px";
  839.             popupNode.style.height = (maxX - ((i - 1) * stepSize)) * hwRatio + "px";
  840.             
  841.             break;
  842.         }
  843.         
  844.         i++;
  845.     }
  846.     
  847.     // Debug
  848.     //window.status = popupNode.offsetWidth + ", " + popupNode.scrollWidth + ", " + popupNode.offsetHeight + ", " + popupNode.scrollHeight;
  849. }
  850.  
  851. function FMCToggler( node )
  852. {
  853.     // Don't continue if something is already popped up
  854.     
  855.     if ( gPopupObj )
  856.     {
  857.         return;
  858.     }
  859.     
  860.     // Toggle the icon
  861.     
  862.     var imgNodes    = node.getElementsByTagName( "img" );
  863.     
  864.     for ( var i = 0; i < imgNodes.length; i++ )
  865.     {
  866.         var imgNode = imgNodes[i];
  867.         
  868.         if ( FMCContainsClassRoot( imgNode.className, "MCTogglerIcon" ) )
  869.         {
  870.             FMCImageSwap( imgNode, "swap" );
  871.             
  872.             break;
  873.         }
  874.     }
  875.     
  876.     // Toggle all toggler items
  877.     
  878.     var targets = FMCGetMCAttribute( node, "MadCap:targets" ).split( ";" );
  879.     
  880.     for ( var i = 0; i < targets.length; i++ )
  881.     {
  882.         var nodes   = FMCGetElementsByAttribute( document.body, "MadCap:targetName", targets[i] );
  883.         
  884.         for ( var j = 0; j < nodes.length; j++ )
  885.         {
  886.             if ( nodes[j].style.display == "none" )
  887.             {
  888.                 nodes[j].style.display = "";
  889.                 
  890.                 FMCUnhide( window, nodes[j] );
  891.             }
  892.             else
  893.             {
  894.                 nodes[j].style.display = "none";
  895.             }
  896.         }
  897.     }
  898. }
  899.  
  900. function FMCSetTextPopupDimensions()
  901. {
  902.     gTextPopupBodyBG.style.width = gTextPopupBody.offsetWidth + "px";
  903.     gTextPopupBodyBG.style.height = gTextPopupBody.offsetHeight + "px";
  904. }
  905.  
  906. function FMCFade()
  907. {
  908.     var finished    = false;
  909.     
  910.     if ( gPopupObj.filters )
  911.     {
  912.         var opacity    = gPopupObj.style.filter;
  913.         
  914.         if ( opacity == "" )
  915.         {
  916.             opacity = "alpha( opacity = 0 )";
  917.         }
  918.         
  919.         gPopupObj.style.filter = "alpha( opacity = " + (parseInt( opacity.substring( 17, opacity.length - 2 ) ) + 10) + " )";
  920.         
  921.         if ( gPopupBGObj )
  922.         {
  923.             opacity = gPopupBGObj.style.filter;
  924.             
  925.             if ( opacity == "" )
  926.             {
  927.                 opacity = "alpha( opacity = 0 )";
  928.             }
  929.             
  930.             gPopupBGObj.style.filter = "alpha( opacity = " + (parseInt( opacity.substring( 17, opacity.length - 2 ) ) + 5) + " )";
  931.         }
  932.         
  933.         if ( gPopupObj.style.filter == "alpha( opacity = 100 )" )
  934.         {
  935.             finished = true;
  936.         }
  937.     }
  938.     else if ( gPopupObj.style.MozOpacity != null )
  939.     {
  940.         var opacity    = gPopupObj.style.MozOpacity;
  941.         
  942.         if ( opacity == "" )
  943.         {
  944.             opacity = "0.0";
  945.         }
  946.         
  947.         gPopupObj.style.MozOpacity = parseFloat( opacity ) + 0.11;
  948.         
  949.         if ( gPopupBGObj )
  950.         {
  951.             opacity = gPopupBGObj.style.MozOpacity;
  952.             
  953.             if ( opacity == "" )
  954.             {
  955.                 opacity = "0.0";
  956.             }
  957.             
  958.             gPopupBGObj.style.MozOpacity = parseFloat( opacity ) + 0.05;
  959.         }
  960.         
  961.         if ( parseFloat( gPopupObj.style.MozOpacity ) == 0.99 )
  962.         {
  963.             finished = true;
  964.         }
  965.     }
  966.     
  967.     if ( finished )
  968.     {
  969.         clearInterval( gFadeID );
  970.         gFadeID = 0;
  971.     }
  972. }
  973.